import java.util.*;

public class Solution {

    //动态规划
    public int maxProfit (int[] prices) {
        int n = prices.length;

        int[] f = new int[n + 1];
        int[] g = new int[n + 1];
        f[0] = -0x3f3f3f3f;
        g[0] = 0;

        for(int i = 1; i <= n; i++){
            f[i] = Math.max(f[i - 1], g[i - 1] - prices[i - 1]);
            g[i] = Math.max(g[i - 1], f[i - 1] + prices[i - 1]);
        }
        return g[n];
    }

    //贪心
    public int maxProfit2 (int[] prices) {
        int n = prices.length, count = 0;

        for(int i = 1; i < n; i++){
            if(prices[i] - prices[i - 1] > 0){
                count += prices[i] - prices[i - 1];
            }
        }
        return count;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        int n = s.length();
        Stack<String> stack = new Stack<>();

        for(int i = 0; i < n;){
            StringBuffer tmp = new StringBuffer();
            while(i < n && s.charAt(i) != ' '){
                tmp.append(s.charAt(i));
                i++;
            }
            if(tmp.toString().length() == 0){
                tmp.append(" ");
                i++;
            }
            stack.add(tmp.toString());
        }

        StringBuffer ret = new StringBuffer();
        while(!stack.isEmpty()){
            ret.append(stack.pop());
        }
        System.out.println(ret.toString());
    }


    public int minMutation(String startGene, String endGene, String[] bank) {

        Set<String> vis = new HashSet<>();
        Set<String> hash = new HashSet<>();
        for(String s : bank) { hash.add(s);}
        char[] change = {'A', 'C', 'G', 'T'};

        if(startGene.equals(endGene)) { return 0;}
        if(!hash.contains(endGene)) { return -1;}

        Queue<String> queue = new LinkedList<>();
        queue.add(startGene);
        vis.add(startGene);
        int step = 0;

        while(!queue.isEmpty()){
            step++;
            int size = queue.size();
            while(size-- != 0){
                String ch = queue.poll();
                for(int j = 0; j < 8; j++){
                    char[] tmp = ch.toCharArray();
                    for(int k = 0; k < 4; k++){
                        tmp[j] = change[k];
                        String next = new String(tmp);
                        if(hash.contains(next) && !vis.contains(next)){
                            if(next.equals(endGene)) { return step;}
                            queue.add(next);
                            vis.add(next);
                        }
                    }
                }
            }
        }
        return -1;
    }


    int[] dx = {0,0,1,-1};
    int[] dy = {1,-1,0,0};
    int m, n;

    public int cutOffTree(List<List<Integer>> forest) {
        m = forest.size();
        n = forest.get(0).size();

        List<int[]> trees = new ArrayList<>();
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                if(forest.get(i).get(j) > 1) { trees.add(new int[]{i,j});}
            }
        }
        Collections.sort(trees, (a, b) -> {
            return forest.get(a[0]).get(a[1]) - forest.get(b[0]).get(b[1]);
        });

        int ret = 0, bx = 0, by = 0;
        for(int[] tree : trees){
            int x = tree[0], y = tree[1];
            int step = bfs(forest, bx, by, x, y);
            if(step == -1) { return -1;}
            ret += step;
            bx = x;
            by = y;
        }
        return ret;
    }
    public int bfs(List<List<Integer>> forest, int bx, int by, int ex, int ey){
        if(bx == ex && by == ey) { return 0;}
        Queue<int[]> queue = new LinkedList<>();
        queue.add(new int[]{bx, by});
        boolean[][] vis = new boolean[m][n];
        vis[bx][by] = true;
        int step = 0;

        while(!queue.isEmpty()){
            step++;
            int size = queue.size();
            while(size-- != 0){
                int[] tmp = queue.poll();
                int a = tmp[0], b = tmp[1];
                for(int i = 0; i < 4; i++){
                    int x = a + dx[i], y = b + dy[i];
                    if(x >= 0 && x < m && y >= 0 && y < n && forest.get(x).get(y) != 0 && !vis[x][y]){
                        if(x == ex && y == ey) { return step;}
                        queue.add(new int[]{x, y});
                        vis[x][y] = true;
                    }
                }
            }
        }
        return -1;
    }

    public int[][] updateMatrix(int[][] mat) {
        int n = mat.length, m = mat[0].length;

        int[][] vis = new int[n][m];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                vis[i][j] = -1;
            }
        }

        Queue<int[]> queue = new LinkedList<>();
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if(mat[i][j] == 0){
                    vis[i][j] = 0;
                    queue.add(new int[]{i, j});
                }
            }
        }

        while(!queue.isEmpty()){
            int[] tmp = queue.poll();
            int a = tmp[0], b = tmp[1];
            for(int i = 0; i < 4; i++){
                int x = a + dx[i], y = b + dy[i];
                if(x >= 0 && x < n && y >= 0 && y < m && vis[x][y] == -1){
                    vis[x][y] = vis[a][b] + 1;
                    queue.add(new int[]{x, y});
                }
            }
        }
        return vis;
    }

    public int numEnclaves(int[][] grid) {
        int m = grid.length, n = grid[0].length;
        boolean[][] vis = new boolean[m][n];

        Queue<int[]> queue = new LinkedList<>();
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                if( i == 0 || i == m - 1 || j == 0 || j == n - 1){
                    if(grid[i][j] == 1){
                        queue.add(new int[]{i, j});
                        vis[i][j] = true;
                    }
                }
            }
        }

        while(!queue.isEmpty()){
            int[] tmp = queue.poll();
            int a = tmp[0], b = tmp[1];
            for(int k = 0; k < 4; k++){
                int x = a + dx[k], y = b + dy[k];
                if(x >= 0 && x < m && y >= 0 && y < n && grid[x][y] == 1 && !vis[x][y]){
                    vis[x][y] = true;
                    queue.add(new int[]{x, y});
                }
            }
        }

        int ret = 0;
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                if(grid[i][j] == 1 && !vis[i][j]){
                    ret++;
                }
            }
        }
        return ret;
    }

    public int[][] highestPeak(int[][] isWater) {
        int m = isWater.length, n = isWater[0].length;
        int[][] dist = new int[m][n];
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                dist[i][j] = -1;
            }
        }

        Queue<int[]> queue = new LinkedList<>();
        for(int i = 0; i < m; i++){
            for(int j = 0; j < n; j++){
                if(isWater[i][j] == 1){
                    queue.add(new int[]{i, j});
                    dist[i][j] = 0;
                }
            }
        }

        while(!queue.isEmpty()){
            int[] tmp = queue.poll();
            int a = tmp[0], b = tmp[1];
            for(int k = 0; k < 4; k++){
                int x = a + dx[k], y = b + dy[k];
                if(x >= 0 && x < m && y >= 0 && y < n && dist[x][y] == -1){
                    dist[x][y] = dist[a][b] + 1;
                    queue.add(new int[]{x, y});
                }
            }
        }
        return dist;
    }

    public int maxDistance(int[][] grid) {
        int n = grid.length;
        int[][] dist = new int[n][n];
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                dist[i][j] = -1;
            }
        }

        Queue<int[]> queue = new LinkedList<>();
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(grid[i][j] == 1){
                    queue.add(new int[]{i, j});
                    dist[i][j] = 0;
                }
            }
        }

        int ret = -1;
        while(!queue.isEmpty()){
            int[] tmp = queue.poll();
            int a = tmp[0], b = tmp[1];
            for(int k = 0; k < 4; k++){
                int x = a + dx[k], y = b + dy[k];
                if(x >= 0 && x < n && y >= 0 && y < n && dist[x][y] == -1){
                    dist[x][y] = dist[a][b] + 1;
                    queue.add(new int[]{x, y});
                    ret = Math.max(ret, dist[x][y]);
                }
            }
        }
        return ret;
    }
}